package f.h.dragon.patterns.mediator;

/**
 * AbstractColleague: This class provides a skeletal implementation of the {@link Colleague} interface.
 * 
 * @author Wenlong Meng(wenlong.meng@gmail.com)
 * @version 1.0 at 2012/04/20
 * @since 1.0
 */
public abstract class AbstractColleague implements Colleague {

	// local variables
	/**
	 * mediator
	 */
	protected Mediator mediator;
	/**
	 * name
	 */
	protected String name;
	
	//Constructor
	/**
	 * Construct the name Colleague
	 * 
	 * @param name 
	 */
	public AbstractColleague(String name){
		this.name = name;
	}

	//Logic
	/**
	 * register Mediator
	 * 
	 * @param mediator
	 * 
	 * @see f.h.dragon.patterns.mediator.Register<T>#register(T)
	 */
	@Override
	public void register(Mediator mediator) {
		this.mediator = mediator;
	}

	/**
	 * assign task to name
	 * 
	 * @see f.h.dragon.patterns.mediator.Colleague#assign(java.lang.String, java.lang.String)
	 */
	@Override
	public void notify(String name, String task) {
		this.mediator.call(name, task);
	}

	/**
	 * get name of colleague
	 * 
	 * @see f.h.dragon.patterns.mediator.Colleague#getName()
	 */
	@Override
	public String getName() {
		return this.name;
	}
	
}
